load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")

cc_binary(
    name = "libv2x_codec.so",
    linkshared = True,
    linkstatic = False,
    deps = [":v2x_codec_lib"],
)

# TODO: add v2x decode
cc_library(
    name = "v2x_codec_lib",
    srcs = ["v2x_encode_component.cc"],
    hdrs = [
      "v2x_encode_component.h",
      "include/v2x-asn-msgs-adapter.hpp",
      "include/v2x-asn-msgs-asn_2.h",
      "include/v2x-asn-msgs-asn_3.h",
      "include/v2x-asn-msgs-common.h",
    ],
    linkopts = [
        "-pthread -lz -lrt -luuid"
    ],
    deps = [
        "//base/device_connect/proto:rsu_data_cc_pb",
        "//middleware/protocol/proto:v2xpb-asn-message-frame_cc_pb",
        "@com_github_google_glog//:glog",
        "@fastrtps//:fastrtps",
        "@com_github_gflags_gflags//:gflags",
        "@airosrt//:airosrt",
        "@asn_wrapper",
    ],
    copts = [
        "-DUSE_CYBERRT",
        "-DMODULE_NAME=\\\"v2x_codec\\\""
    ]
)

cc_test(
     name="v2x_codec_ut",
     srcs = [
        "ut/v2x_encode_component_test.cc",
        "v2x_encode_component.h",
     ],
    linkopts = [
        "-pthread -lz"
    ],
    deps=[
      "@com_google_googletest//:gtest_main",
      ":v2x_codec_lib",
    ],
    copts = [
        "-DUSE_CYBERRT"
    ],
    linkstatic = False,
)